import React from "react";
import { AtForm, AtInput } from "taro-ui";
import { Picker, View, Text } from "@tarojs/components";

export default (props) => {
  // 下拉改变
  const pickerChange = (value) => {
    const index = value.detail.value;
    const code = props.sysParam.order_sex[index].paramCode;
    props.change("genderCode", code);
  };
  return (
    <>
      <AtForm>
        <AtInput
          title="姓名*"
          name="name"
          value={props.data.name}
          onChange={props.change.bind(this, "name")}
          placeholder="请输入患者姓名"
        />
        <Picker
          className="at-input"
          range={props.sysParam.order_sex}
          rangeKey="paramDesc"
          onChange={pickerChange}
        >
          <Text className="at-input__title">性别</Text>
          <View className="pickerCont at-input__input">
            {props.data.genderCode
              ? props.sysParam?.order_sex.find(
                  (item) => item.paramCode === props.data.genderCode
                )?.paramDesc
              : "请选择患者性别"}
          </View>
        </Picker>
        <AtInput
          title="年龄"
          name="age"
          value={props.data.age}
          onChange={props.change.bind(this, "age")}
          placeholder="请输入患者年龄"
        />
        <AtInput
          title="电话"
          name="phoneNumber"
          value={props.data.phoneNumber}
          onChange={props.change.bind(this, "phoneNumber")}
          placeholder="请输入患者电话"
        />
      </AtForm>
    </>
  );
};
